package fr.unice.guitartools;

import fr.unice.guitartools.metronome.Metronome;
import fr.unice.guitartools.RingdroidSelectActivity;
import fr.unice.guitartools.R;
import fr.unice.guitartools.recorder.AudioRecorderActivity;
import fr.unice.guitartools.tuner.TunerActivity;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.graphics.drawable.StateListDrawable;
import android.net.Uri;
import android.os.Bundle;

/*
 * This class contents home page of the application with menu, and action on it.
 */
public class GuitarToolsActivity extends Activity{

	Button buttonPlay = null;
	Button buttonRec = null;
	Button buttonTab = null;
	Button buttonLyric = null;
	Button buttonMetronome = null;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		//Resources res = getResources();
		StateListDrawable myButton2 = new StateListDrawable();
		// myButton2.addState(new int[] {android.R.attr.state_pressed}, res.getDrawable(R.drawable.button2));
		//myButton2.addState(new int[] {android.R.attr.state_focused}, res.getDrawable(R.drawable.button3));
		//myButton2.addState(new int[] {}, res.getDrawable(R.drawable.button2));


		((Button)findViewById(R.id.play)).setBackgroundDrawable(myButton2);
		((Button)findViewById(R.id.rec)).setBackgroundDrawable(myButton2);
		((Button)findViewById(R.id.tab)).setBackgroundDrawable(myButton2);
		((Button)findViewById(R.id.lyrics)).setBackgroundDrawable(myButton2);
		((Button)findViewById(R.id.about)).setBackgroundDrawable(myButton2);
		((Button)findViewById(R.id.metronome)).setBackgroundDrawable(myButton2);
		((Button)findViewById(R.id.tuner)).setBackgroundDrawable(myButton2);

		//find button play
		buttonPlay = (Button)findViewById(R.id.play);
		//monBouton.setOnClickListener(this);
		// action sur button play (ouvre une nouvelle fenetre
		buttonPlay.setOnClickListener(new View.OnClickListener() {
			public void onClick(View arg0) {
				// call new screen
				Intent i = new Intent(GuitarToolsActivity.this, RingdroidSelectActivity.class);
				startActivity(i);

			} 
		});

		
		
		// find button Rec
		buttonRec = (Button)findViewById(R.id.rec);
		buttonRec.setOnClickListener(new View.OnClickListener() {
			public void onClick(View arg0) {
			
				Intent i = new Intent(GuitarToolsActivity.this, AudioRecorderActivity.class);
				startActivity(i);
			} 
		});

		// find button tab
		buttonTab = (Button)findViewById(R.id.tab);
		buttonTab.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				String url = "http://www.911tabs.com/";  
				Intent i = new Intent(Intent.ACTION_VIEW);  
				i.setData(Uri.parse(url));  
				startActivity(i);  
				
			}
		});
		
		// find button Lyric
		buttonLyric = (Button)findViewById(R.id.lyrics);
		buttonLyric.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				String url = "http://www.azlyrics.com/lyrics/";  
				Intent i = new Intent(Intent.ACTION_VIEW);  
				i.setData(Uri.parse(url));  
				startActivity(i); 
			}
		});
		
		// find button Tuner
		buttonRec = (Button)findViewById(R.id.tuner);
		buttonRec.setOnClickListener(new View.OnClickListener() {
			public void onClick(View arg0) {
				Intent i = new Intent(GuitarToolsActivity.this, TunerActivity.class);
				startActivity(i);

			} 
		});
		
		// find button Metronome
		buttonMetronome = (Button)findViewById(R.id.metronome);
		buttonMetronome.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				Intent i = new Intent(GuitarToolsActivity.this, Metronome.class);
				startActivity(i);
				
			}
		});
		
		
	}
	


}